home *** CD-ROM | disk | FTP | other *** search
/ Stone Design / Stone Design.iso / Stone_Friends / Wave / WavesWorld / Source / IBPalettes / WW3DKit / WWDADLightView.m < prev    next >
Encoding:
Text File  |  1995-03-22  |  2.4 KB  |  89 lines

  1. // copyright 1993 Michael B. Johnson; some portions copyright 1994, MIT
  2. // see COPYRIGHT for reuse legalities
  3. //
  4.  
  5.  
  6. #import "WWDADLightView.h"
  7.  
  8. @implementation WWDADLightView
  9.  
  10. - initFrame:(const NXRect *)r 
  11. {
  12.    const char  *dragTypes[] = { NXAsciiPboardType, NULL};
  13.  
  14.    [super initFrame:r];
  15.    [self registerForDraggedTypes:dragTypes count:1];
  16.    alpha = 0.0;
  17.    [self setImageFile:"light12Small"];
  18.    return self;
  19. }
  20.  
  21. - awake
  22. {
  23.    const char  *dragTypes[] = { NXAsciiPboardType, NULL};
  24.  
  25.  
  26.    [super awake];
  27.    [self registerForDraggedTypes:dragTypes count:1];
  28.    return self;
  29. }
  30.  
  31. - free
  32. {
  33.    const char *fileType[] = { "" };
  34.    Pasteboard *pboard = [Pasteboard newName:NXDragPboard];
  35.  
  36.  
  37.    [pboard declareTypes:fileType num:0 owner:nil];
  38.    [self unregisterDraggedTypes];
  39.    image = nil; // don't free the potentially shared image
  40.  
  41.    return [super free];
  42. }
  43.  
  44.  
  45. - setLightType:(N3DLightType)newLightType  { lightType = newLightType; return self; }
  46. - (N3DLightType)lightType  { return lightType; }
  47.  
  48. /*-------------------- methods to be the source of a dragging operation */
  49.  
  50. - mouseDown:(NXEvent *)theEvent
  51. {
  52.    NXPoint  zero = {0.0, 0.0};
  53.    id       thePboard;
  54.    const char  *dragTypes[] = { NXAsciiPboardType, NULL};
  55.    static char *fooBarBaz = "fooBarBaz";
  56.  
  57.     
  58.    if (!image) { return self; }
  59.  
  60.    // Prevent default window ordering (this is a new appkit feature)
  61.    [NXApp preventWindowOrdering];
  62.  
  63.    //get the Pboard
  64.    thePboard = [Pasteboard newName:NXDragPboard];
  65.    [thePboard declareTypes:dragTypes num:1 owner:nil];
  66.  
  67.    // we're not really going to use this info, we're just sticking something on the board...
  68.    [thePboard writeType:NXAsciiPboardType data:fooBarBaz length:(1 + strlen(fooBarBaz))];
  69.     
  70.    //start the drag
  71.    [self dragImage:image    // visible on screen during drag
  72.                 at:&zero    // offset the mouse point for the drag
  73.             offset:&zero    // offset the inital mouse pt
  74.              event:theEvent    // theEvent structure
  75.         pasteboard:thePboard    // a Pasteboard with data on it
  76.             source:self        // source object
  77.          slideBack:YES];    // if no destination animate back to source
  78.     
  79.     return self;
  80. }
  81.  
  82. - draggedImage:(NXImage *)image beganAt:(NXPoint *)screenPoint  { return self; }
  83.  
  84. - (NXDragOperation)draggingSourceOperationMaskForLocal:(BOOL)flag  { return (NX_DragOperationCopy | NX_DragOperationGeneric); }
  85.  
  86. - draggedImage:(NXImage *)image endedAt:(NXPoint *)screenPoint deposited:(BOOL)flag { return self; }
  87.  
  88. @end
  89.